<template>
    <div class="adb">
        <img :src="$store.state.gg" alt="">
        <div class="tgbox">
            <span @click="tiaoguo">{{sj}}秒 跳过</span>
        </div>
        
        <mylogo></mylogo>
    </div>
</template>
<script>
import mylogo from "../small/mylogo.vue"
export default {
    name:"ad",
    components:{
        mylogo
    },
    data(){
        return {
            sj:8,
            tim:null
        }
    },
    created(){
        let yougg = sessionStorage.getItem("gg")
       if(yougg){
        this.$router.push("/index")
       }else{
        this.$store.commit('changenavshow', false)
        // console.log(this.$store.state.gg)
        this.daojishi()
       }
    },
    methods:{
        daojishi(){
            this.tim = setInterval(()=>{
                this.sj -= 1
                if(this.sj === 0){
                    clearInterval(this.tim)
                    sessionStorage.setItem("gg",true)
                    this.tim = null
                    this.$router.push("/index")
                }
            },1000)
        },
        tiaoguo(){
            clearInterval(this.tim)
            this.tim = null
            sessionStorage.setItem("gg",true)
            this.$router.push("/index")
        }
    }
}
</script>
<style lang="less">
img{
    width: 100%;
    height:100%;
}
.tgbox{
    position: absolute;
    top:3%;
    right:5%;
    background-color: rgba(51, 51, 51, 0.356);
    padding:0.2rem;
    font-size:0.4rem;
    color:white;
    border-radius: 50px;
    span{

    }
}
</style>